<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<script type="text/javascript" src="${ctx}/scripts/checktool.js"></script>

<div class="spaw730nav">
	<p class="sHB00 fl">修改用户信息</p>
</div>
<div class="spalisdiv">
	<div class="spalistmater">
		<form id="f_user_profile" action="<c:url value='/user/saveprofile.do'/>" method="post">
			<table class="t_mid4" cellpadding="5px" cellspacing="0">
				<tr>
					<td class="t_mid4_td_tit">身高</td>
					<td class="t_mid4_td_cnt">
						<ms:inc end="230" name="userProfile.height" step="1" start="140" selected="${userProfile.height}"></ms:inc>
						<font style="color:red;">CM</font>
					</td>
					<td class="t_mid4_td_tit">体重</td>
					<td class="t_mid4_td_cnt">
						<ms:inc end="100" name="userProfile.weight" step="2" start="40" selected="${userProfile.weight}"></ms:inc>
						<font style="color:red;">KG</font>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">星座</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.asterism" type="asterism" selected="${userProfile.asterism}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">性格</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.characterise" type="characterise" selected="${userProfile.characterise}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">血型</td>
					<td class="t_mid4_td_cnt">
					<ms:select name="userProfile.bloodType" type="bloodType" selected="${userProfile.bloodType}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">体型</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.bodyType" type="bodyType" selected="${userProfile.bodyType}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">吸烟情况</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.smoke" type="smoke" selected="${userProfile.smoke}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">喝酒情况</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.drink" type="drink" selected="${userProfile.drink}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">是否已婚</td>
					<td class="t_mid4_td_cnt3">
						<ms:select name="userProfile.married" type="married" selected="${userProfile.married}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">薪水</td>
					<td class="t_mid4_td_cnt">
						<ms:select name="userProfile.salary" type="SALARY" selected="${userProfile.salary}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">现在居住地</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<ms:city type="select" pname="presidence" pid="presidence" onchange="modifychild('presidence', 'cresidence')" cname="userProfile.residence" cid="cresidence" code="${userProfile.residence}"></ms:city>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">住址</td>
					<td class="t_mid4_td_cnt">
						<input class="input" type="text" id="user_address" name="userProfile.address" value="${userProfile.address}"/>
					</td>
					<td class="t_mid4_td_tit">住址邮编</td>
					<td class="t_mid4_td_cnt">
						<input class="input" type="text" id="user_postal" name="userProfile.postal" value="${userProfile.postal}"/>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">家乡</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<ms:city type="select" pname="phometown" pid="phometown" onchange="modifychild('phometown', 'chometown')" cname="userProfile.hometown" cid="chometown" code="${userProfile.hometown}"></ms:city>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">学历</td>
					<td  class="t_mid4_td_cnt">
					<ms:select name="userProfile.eduDegree" type="eduDegree" selected="${userProfile.eduDegree}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">专业</td>
					<td  class="t_mid4_td_cnt">
					<ms:select name="userProfile.eduSpecialty" type="eduSpecialty" selected="${userProfile.eduSpecialty}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">学校</td>
					<td class="t_mid4_td_cnt">
						<input class="input" type="text" id="user_edu_school" name="userProfile.eduSchool" value="${userProfile.eduSchool}"/>
					</td>
					<td class="t_mid4_td_tit">入学时间</td>
					<td class="t_mid4_td_cnt">
						<ms:inc end="2020" name="userProfile.eduEnrolYear" step="1" start="1978" selected="${userProfile.eduEnrolYear}"></ms:inc>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">公司</td>
					<td class="t_mid4_td_cnt">
						<input class="input" type="text" id="user_job_company" name="userProfile.jobCompany" value="${userProfile.jobCompany}"/>
					</td>
					<td class="t_mid4_td_tit">入值时间</td>
					<td class="t_mid4_td_cnt">
						<ms:inc end="2020" name="userProfile.jobEnrolYear" step="1" start="1978" selected="${userProfile.jobEnrolYear}"></ms:inc>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">职位</td>
					<td class="t_mid4_td_cnt">
					<ms:select name="userProfile.jobTitle" type="jobTitle" selected="${userProfile.jobTitle}"></ms:select>
					</td>
					<td class="t_mid4_td_tit">从事行业</td>
					<td  class="t_mid4_td_cnt">
					<ms:select name="userProfile.jobProfession" type="jobProfession" selected="${userProfile.jobProfession}"></ms:select>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">兴趣爱好</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<ul>
							<ms:checkbox name="userProfile.favOthers" type="favOthers" selected="${userProfile.favOthers}"></ms:checkbox>
						</ul>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">喜欢的运动</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<ul>
						<ms:checkbox name="userProfile.favSports" type="favSports" selected="${userProfile.favSports}"></ms:checkbox>
						</ul>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">喜欢的电影</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<textarea name="userProfile.favMoive" cols="60" rows="5"><c:out value="${userProfile.favMoive}"/></textarea>
						<br/>
						<font style="color:red;">不同的电影请用，分割</font>
					</td>
				</tr>
				<tr>
					<td class="t_mid4_td_tit">喜欢的书籍</td>
					<td colspan="3" class="t_mid4_td_cnt3">
						<textarea name="userProfile.favBook" cols="60" rows="5"><c:out value="${userProfile.favBook}"/></textarea>
						<br/>
						<font style="color:red;">不同的书籍请用，分割</font>
					</td>
				</tr>
				<tr>
					<td colspan="3" style="text-align:center;height:50px;background-color:#FFEDED;font-size: 20px;font-weight:bold">
					<a class="but82" href="javascript:saveUserProfile();">保&nbsp;&nbsp;&nbsp;存</a>
					</td>
				</tr>
			</table>
		</form>
	</div>
</div>

<script>
function saveUserProfile(){
	$.ajax({
			type : "POST",
			url : "<c:url value='/user/saveprofile.do'/>",
			data:$("#f_user_profile").serialize(),
			timeout:20000,
			success : function(data){
				if($(data).find('result').text().toUpperCase().indexOf("TRUE") >= 0){
					userinfoTab(3);
				}
			},
			error: function(){
			}
		});
}
function modifychild(parent, child){
	var choose = "#"+parent+" option:selected";
	var p = $(choose).val();
	$.ajax({
		type : "POST",
		url : "<c:url value='/city/child.do'/>",
		data : "code=" + p,
		dataType:"html", 
		timeout:20000,
		success : function(data){
			$("#"+child).empty();
			$(data).find("item").each(function(){
				//	alert($(this).find("value").text());
		            $("<option></option>").text($(this).find("value").text()).val($(this).find("position").text()).appendTo($("#"+child));
		        });
		},
		error: function(){
		}
	});
}
</script>